package com.tianji.remark.controller;


import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author LYQ
 * @since 2024-06-28
 */
@Api("点赞服务相关接口")
@RestController
@RequestMapping("/likes")
@RequiredArgsConstructor
public class LikedRecordController {
private final ILikedRecordService likedRecordService;

    /**
     * 点赞或取消点赞
     * @param likeRecordDTO
     */
    @PostMapping
    @ApiOperation("点赞或取消点赞")
    public void addLikedRecord(@Valid @RequestBody LikeRecordFormDTO likeRecordDTO){
        likedRecordService.addLikedRecord(likeRecordDTO);
    }

    /**
     * 根据业务ID集合查询是否已经点赞
     * @param bizIds
     */
    @GetMapping("/list")
    @ApiOperation("点赞或取消点赞")
    public Set<Long> isLiked(@RequestParam("bizIds") List<Long> bizIds){
        return likedRecordService.isLiked(bizIds);
    }
}
